<?php
//No direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class OwnserviceControllerSetting extends OwnserviceController
{
	/*
	 * Controller construct
	*/
	function __construct(){

		parent::__construct();
	}

	/**
	 * Logic to save settings
	 * 
	 * @access public
	 * @return void
	*/
	function save(){

		//Check for request forgeries
		JRequest::checkToken() or jexit('Invalid Token');

		$user	= &  JFactory::getUser();
		$app	= & JFactory::getApplication();

		// Get vars
		$post = JRequest::getVar( 'setting',array(), 'post', 'array' );

		$model = $this->getModel('Settings');

		$type = '';

		if($model->store($post)){
			$msg = JText::_('OWNSERVICE_SETTINGS_SAVED');
		} else {
			$type = 'error';
			$msg = JText::_('OWNSERVICE_ERROR_SAVING_SETTINGS');
		}

		$link = JRoute::_('index.php?option=com_ownservice&view=settings');

		$this->setRedirect($link, $msg, $type);
	}

	/**
	 * logic for cancel an action
	 *
	 * @access public
	 * @return void
	 * @since 1.0
	 */
	function cancel()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$app	= & JFactory::getApplication();

		$link = JRoute::_('index.php?option=com_ownservice');

		$this->setRedirect( $link );
	}
}